package com.veryUsedCar.service.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.veryUsedCar.entity.CarInfoLab;
import com.veryUsedCar.entity.Conllection;
import com.veryUsedCar.entity.Labels;
import com.veryUsedCar.mapper.CarInfoLabMapper;
import com.veryUsedCar.mapper.CollectionMapper;
import com.veryUsedCar.mapper.LabelsMapper;
import com.veryUsedCar.service.CollectionService;
import lombok.extern.slf4j.Slf4j;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.nio.channels.SelectableChannel;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

/**
 * author  woo
 * date 2022/11/18 18:17
 * 描述：
 */
@Slf4j
@Service
public class CollectionServiceImpl implements CollectionService {
    @Autowired
    private CollectionMapper collectionMapper;
    @Autowired
    private CarInfoLabMapper carInfoLabMapper;
    @Autowired
    private LabelsMapper labelsMapper;

    @Override
    public List<Conllection> getCollection() {
        return collectionMapper.selectList(null);
    }

    // 收藏页面的编辑
    @Override
    public void deleteCollection(List<Long> ids) {
        collectionMapper.deleteBatchIds(ids);
    }

    // 收藏页面的为你推荐
    @Override
    public void findRecommend(List<Long> ids) {
        QueryWrapper queryWrapper = new QueryWrapper();
        // 先查询车辆的信息中对应的标签
        List<CarInfoLab> list = carInfoLabMapper.selectBatchIds(ids);

        // 根据查询到的车辆信息获取对应的标签
        List<String> list1 = new ArrayList<>(); // 先创建一个集合备用
        for (CarInfoLab carInfoLab : list) { // 遍历收藏后的车辆信息的id,然后根据id查询所有标签,所得到的标签存放到集合中
            Long labId = carInfoLab.getLabId();
            Labels labels = labelsMapper.selectById(labId);
            String labName = labels.getLabName();
            list1.add(labName);
        }
        // 此时所有收藏过的车辆信息中的标签已经在集合中,等待换其他思路
//        // 根据这些关键字查询所有由此关键字的所有车辆信息;
//        for (String s : list1) {
//
//        }
    }


}
